class ActiveRecord::ConnectionAdapters::PostgreSQLAdapter < ActiveRecord::ConnectionAdapters::AbstractAdapter
  def add_referential_integrity(table, keypairs)
    keypairs.each_pair do |foreign_key, foreign_table|
      execute "ALTER TABLE #{table} ADD CONSTRAINT #{table}_fk_#{foreign_key} FOREIGN KEY (#{foreign_key}) REFERENCES #{foreign_table} (id)"
    end
  end

  def drop_referential_integrity(table, keys)
    keys.each do |foreign_key|
      execute "ALTER TABLE #{table} DROP CONSTRAINT IF EXISTS #{table}_fk_#{foreign_key}"
    end
  end
end
